import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	static Scanner cin = null;
	static {
		try {
			cin = new Scanner(new FileReader(new File("A.in")));
		} catch (IOException e) {
			cin = new Scanner(System.in);

		}

	}

	public static void main(String[] args) {
		final String regex="^(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)(\\.(25[0-5]|2[0-4]\\d|[0-1]?\\d?\\d)){3}$";
		while(cin.hasNextLine()){
			String input=cin.nextLine();

			if(Pattern.matches(regex,input)) {
				System.out.println("Y");
			}else {
				System.out.println("N");
			}
		}

	}

}